#include<iostream>
#include<memory>
using std::shared_ptr;
using std::cout;
using std::endl;

class Point{
public:
    Point(int x,int y):_x(x),_y(y){}
    Point*add(Point*rhs){
        _x +=rhs->_x;
        _y +=rhs->_y;
        return this;
    }
    Point getPoint(){
        return *this;
    }
    void Print(){
        cout<<_x<<" "<<_y<<endl;
    }
    ~Point(){
        cout<<"~Point"<<endl;
    }
private:
    int _x;
    int _y;
};
void test(int a,Point p){
    cout<<a<<endl;
}

int main(void){
    //Point p;
    //test(3,Point());//Point p = Point();
    Point *p1 = new Point(3,4);
    shared_ptr<Point>sp1(p1);
    Point*p2 = new Point(1,3);
    shared_ptr<Point>sp2(p2);
    sp1->add(sp2.get());
    sp1->Print();
    shared_ptr<Point>sp3(sp1->add(sp2.get()));
    //shared_ptr<Point>sp3(sp1);//这样是赋值
}